// const axios = require("axios");
// const fs = require("fs");

// let imgUrl = "https://p26-passport.byteacctimg.com/img/mosaic-legacy/3791/5070639578~100x100.awebp";
// loadImg(imgUrl);

// async function loadImg(imgUrl) {
//     let writer = fs.createWriteStream(Date.now() + ".jpg");
//     const response = await axios({
//         url: imgUrl,
//         method: "GET",
//         responseType: "stream"
//     });
//     response.data.pipe(writer);
// }
let URL = "http://49.51.69.50:3000/video/download";

post({
    video: "https://ssscdn.io/ssstwitter/aHR0cHM6Ly92aWRlby50d2ltZy5jb20vZXh0X3R3X3ZpZGVvLzE2NTYyOTEwMDUzNjc0NjgwMzQvcHUvdmlkLzcyMHgxMjgwL0Z3NzRBVk4xZ25VZ1ljQ0MubXA0P3RhZz0xMg=="
})

// let URL = "http://49.51.69.50:3000/video/upload";
// post({
//     name: "1705847449143.mp4"
// })
function post(param) {
    fetch(URL, {
        method: "POST",
        headers: {
            "Content-Type": "application/json"
        },
        body: JSON.stringify(param)
    })
        .then(response => response.json())
        .then(res => {
            console.log(res);
            if(res.name){
                msg("保存成功");
            } else {
                msg("保存失败");
            }
        })
        .catch(error => {
            msg("保存错误");
        });
}

function msg(str) {
    console.log(str);
}